Chord diagrams

using bokeh
vizualisation
Published

January 17, 2023

Need

Generate quickly such vizualisations

image.png

Using bokeh

import pandas as pd
import holoviews as hv
from holoviews import opts, dim
from bokeh.sampledata.les_mis import data

hv.extension('bokeh')
hv.output(size=200)
links = pd.DataFrame(data['links'])
print(links.head(3))
   source  target  value
0       1       0      1
1       2       0      8
2       3       0     10
# libraries
import pandas as pd
import holoviews as hv
from holoviews import opts, dim
from bokeh.sampledata.les_mis import data

# data set
nodes = hv.Dataset(pd.DataFrame(data['nodes']), 'index')

# chord diagram
chord = hv.Chord((links, nodes)).select(value=(5, None))
chord.opts(
    opts.Chord(cmap='Category20', edge_cmap='Category20', edge_color=dim('source').str(), 
               labels='name', node_color=dim('index').str()))
nodes
:Dataset   [index]   (name,group)